how to chain rule with 3 functions